
<!DOCTYPE html>
<html>
<head>
    <title>ManaGement PlatForm</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="format-detection" content="telephone=no">
    <meta name="_csrf" content="b9f45982-508d-4901-a0c4-772de2381fc8"/>
    <meta name="_csrf_header" content="X-CSRF-TOKEN" />
    <link href="/Admin/resources/upload/favicon.png?v=20211126125129" rel="shortcut icon"/>
    <!--[if IE 8]>
    <script src="/wedding_admin/statics/js/um/respond.min.js"></script>
    <script src="/wedding_admin/statics/js/um/es5-shim.min.js"></script>
    <![endif]-->
    <script src="/wedding_admin/statics/js/jquery.min.js"></script>
    <script src="/wedding_admin/statics/js/kendo.all.min.js?v=20180330"></script>
    <script src="/wedding_admin/statics/js/jszip.min.js"></script>

    <link href="/wedding_admin/statics/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="/wedding_admin/statics/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>

    <link href="/wedding_admin/statics/css/um/kendo.common-bootstrap.min.css?v=20180330" rel="stylesheet" type="text/css"/>
    <link href="/wedding_admin/statics/css/um/kendo.bootstrap.min.css?v=20180330" rel="stylesheet" type="text/css"/>

    <!-- <link href="/Admin/lib/kendoui/styles/kendo.common.min.css" rel="stylesheet" type="text/css"/>
    <link href="/Admin/lib/kendoui/styles/kendo.uniform.min.css" rel="stylesheet" type="text/css"/> -->

    <link href="/wedding_admin/statics/css/um/kendo.hap.css?v=20180330" rel="stylesheet" type="text/css"/>
    <script src="/wedding_admin/statics/js/kendo.culture.zh-CN.js?v=20180330"></script>
    <script src="/wedding_admin/statics/js/kendo.messages.zh-CN.js?v=20180330"></script>
    <script src="/wedding_admin/statics/js/kendo.hap.js?v=20180330"></script>
    <script src="/wedding_admin/statics/js/plugins/jquery.blockui.min.js"></script>

    <script>
        _basePath = '/Admin', _locale = 'zh_CN';
        kendo.culture("zh-CN");
        _currentFunctionCode = 'MY_PROFILE';
        window.accessConfig = {};
        hotKeys = [];
    </script>
    <script src="/Admin/common/hotkey"></script>
    <script src="/Admin/common/prompts"></script>
</head>
<script src="/Admin/common/code?passwordComplexity=SYS.PASSWORD_COMPLEXITY"
        type="text/javascript"></script>
<body>
<div id="page-content">
    <div class="form-horizontal" id="userInformation">
        <div >
            <div class="panel-body">
                <div class="form-group">
                    <label class="control-label col-sm-3">用户名</label>
                    <div class="col-sm-4" >
                        <input name="userName" readonly style="background-color:#DEDEDE;width: 100%" type="text" data-bind="value:model.userName" class="k-textbox">
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-sm-3">邮件</label>
                    <div class="col-sm-4" >
                        <input type="email" name="email" required validationMessage="请输入正确的Email信息" style="width: 100%" data-bind="value:model.email" class="k-textbox">
                    </div>
                    <div class="col-sm-2" >
                        <span class="k-invalid-msg" data-for="email"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-sm-3">电话</label>
                    <div class="col-sm-4" >
                        <input type="tel" name="phone" pattern="^1[3|4|5|8][0-9]\d{4,8}$" style="width: 100%" required validationMessage="请输入正确的电话信息" data-bind="value:model.phone" class="k-textbox">
                    </div>
                    <div class="col-sm-2" >
                        <span class="k-invalid-msg" data-for="phone"></span>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-3" >
                        <button class="btn btn-primary" style="width:100px" data-bind="enabled:enabled,click:saveUserInfor">保存</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var userInforValidator = $("#userInformation").kendoValidator().data("kendoValidator");
        //定义一个viewModel
        var userInforViewModel = kendo.observable({
            enabled:true,
            model:{
                userName: "019509111",
                email:"ruans@jtgroup.com.cn",
                phone: "662360",
                _token: "b840dc55e09d7d59999eafb3fbe70cfc"
            },
            saveUserInfor: function(){
                var sf = this;
                if(!userInforValidator.validate()){
                    return;
                }
                sf.set('enabled', false)
                $.ajax({
                    type: "POST",
                    url: "/Admin/sys/user/update",
                    contentType: "application/json",
                    data: kendo.stringify(userInforViewModel.toJSON().model),
                    dataType: "json",
                    success: function (result) {
                        if (result.success) {
                            kendo.ui.showInfoDialog({
                                message:'操作成功'
                            }).done(function(){
                                location.reload()
                            })
                        }else{
                            kendo.ui.showErrorDialog({
                                message:result.message
                            })
                        }
                    }
                }).complete(function(){
                    sf.set('enabled', true)
                });
            }
        });
        kendo.bind($('#userInformation'),userInforViewModel);
    </script>
    <div class="form-horizontal" id="updatePassword">
        <div class="">
            <div class="panel-heading">
                <span class="panel-title">修改密码</span>
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="control-label col-sm-3">当前密码</label>
                    <div class="col-sm-4" >
                        <input name="oldPwd" style="width:100%" required validationMessage="当前密码不能为空" type="text" data-bind="value:model.oldPwd" class="password-input k-textbox">
                    </div>
                    <div class="col-sm-3" >
                        <span class="k-invalid-msg" data-for="oldPwd"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-3">新密码</label>
                    <div class="col-sm-4" >
                        <input name="newPwd" style="width:100%"  required  data-message="新密码不能为空"  type="text" data-bind="value:model.newPwd" class="password-input k-textbox">
                        <small class="help-block">
                            <script>
                                $.each(passwordComplexity,function(i,v){
                                    if( "no_limit" == v.value ){
                                        document.write('密码长度不能小于8 ');
                                        if("no_limit"!= "no_limit")
                                        {
                                            document.write(v.meaning);
                                        }
                                    }
                                });
                            </script>
                        </small>
                    </div>
                    <div class="col-sm-3" >
                        <span class="k-invalid-msg" data-for="newPwd"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-3">确认新密码</label>
                    <div class="col-sm-4" >
                        <input name="newPwdAgain" style="width:100%" required data-message='请再次输入新密码' type="text" data-bind="value:model.newPwdAgain" class="password-input k-textbox">
                    </div>
                    <div class="col-sm-3" >
                        <span class="k-invalid-msg" data-for="newPwdAgain"></span>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-3" >
                        <button class="btn btn-primary" style="width:100px" data-bind="enabled:enabled,click:savePassword">保存</button>
                    </div>
                </div>
                <script type="text/javascript">
                    $('.password-input').one('focus',function(){
                        $(this).attr('type','password');
                    })
                </script>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        //弹出框密码验证结束
        var passwordViewModel = kendo.observable({
            enabled:true,
            model:{
                length: "8",
                complexity:"no_limit"
            },
            passwordComplexityData:passwordComplexity,
            savePassword: function(){
                if(validator.validate()){

                    $.ajax({
                        type : 'post',
                        async : false,
                        url :"/Admin/sys/user/password/update",
                        data : passwordViewModel.toJSON().model,
                        dataType : 'json',
                        success: function(result){
                            if (result.success) {
                                kendo.ui.showInfoDialog({
                                    message: '操作成功'
                                }).done(function(){
                                    location.reload();
                                })
                            }else{
                                kendo.ui.showErrorDialog({
                                    message:result.message
                                })
                            }
                        }
                    });

                }
            }
        });
        kendo.bind($('#updatePassword'), passwordViewModel);


        var newPasComplexity = passwordViewModel.model.passwordcomplexity;
        var validator = $("#updatePassword").kendoValidator({
            messages: {
                required:function(input) {
                    return input.data("message");
                },
                match :'密码输入不一致'
            },
            rules: {
                passwordlength:function(input){
                    if (input.is("[name=newPwd]")) {
                        if(input.val().length < "8"){
                            return false;
                        }
                    }
                    return true;
                },
                password: function(input) {
                    var flag = input.is("[name=newPwd]");
                    if (flag) {
                        return Hap.passwordFormat(input.val(),"no_limit");
                    }
                    return true;
                },
                match : function(input){
                    if (input.is("[name=newPwdAgain]")) {
                        var newPwd = passwordViewModel.model.newPwd;
                        var newPwdAgain = input.val();
                        if(newPwd!==null && newPwdAgain!== null && newPwd!=="" && newPwdAgain!== ""){
                            if(newPwd == newPwdAgain){
                                return true;
                            }
                            return false;
                        }
                    }
                    return true;
                }
            }
        }).data("kendoValidator");

        validator.options.messages.passwordlength = '密码长度不能小于8';
        $.each(passwordComplexity,function(i,v){
            if( "no_limit" == v.value){
                validator.options.messages.password = v.meaning;
            }
        });
    </script>
</div>
</body>